# -*- coding: utf-8 -*-
"""
-------------------------------------------------
Project Name: luffcity study project
File Name: student_interface.py
Author: kij
Create Date: 2021/2/22
-------------------------------------------------
"""
from modle.modles import Student,Lesson
from interface import common_interface


def register_interface(user_name, user_password):
	student = Student(user_name, user_password)
	student.save_data()
	return True, '注册成功'


# 学生选择学校
def select_school_interface(school_name, user_name):
	student = Student.get_data(user_name)
	student.add_school(school_name)
	return True, '选择成功!'

def get_my_school_lesson(user_name):
	student = Student.get_data(user_name)
	lesson_list = common_interface.get_all_lesson(student.school)
	if len(lesson_list)>0:
		return True ,lesson_list
	else:
		return False ,'你选的学校没有课程'


# 学生选择课程
def select_lesson_interface(lesson_name, user_name):
	student = Student.get_data(user_name)
	if lesson_name in student.lessons:
		return False, '%s课程已经选择了!' % lesson_name
	else:
		student.add_lesson(lesson_name)
		return True, '%s选择成功!' % lesson_name


def select_score_interface(user_name):
	student = Student.get_data(user_name)
	if student.score_dict:
		return student.score_dict